package com.czy.workflow.core.service.dao;

import com.czy.workflow.core.model.FlowRuntimeNode;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

public interface FlowRuntimeNodeRepository extends JpaRepository<FlowRuntimeNode, String> {

    List<FlowRuntimeNode> findByDocId(String docId);

    boolean existsByDocIdAndNodeId(String docId, String nodeId);

    @Modifying
    @Query("delete from FlowRuntimeNode n where n.docId = ?1")
    int deleteByDocId(String docId);

    @Modifying
    @Query("delete from FlowRuntimeNode n where n.docId = ?1 and n.nodeId = ?2")
    int deleteByDocIdAndNodeId(String docId, String nodeId);

}
